﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fraction
{
    class Fraction : IFormattable
    {
        private int numerator;
        private int denumerator;

        public Fraction(int numerator, int denumerator)
        {
            this.numerator = numerator;
            this.denumerator = denumerator;
        }

        public int Numerator
        {
            get
            {
                return numerator;
            }
            set
            {
                numerator = value;
            }
        }

        public int Denumerator
        {
            get
            {
                return denumerator;
            }
            set
            {
                denumerator = value;
            }
        }
        public string ToString(string format, IFormatProvider formatProvider)
        {
            try
            {
                if (format == "R")
                    return string.Format("{0:0.00}", (double)numerator / (double)denumerator);
                if (format == "N")
                    return numerator + "/" + denumerator;

                throw new ArgumentException("The Format is wrong");
            }
            catch (ArgumentException) 
            {
                Console.WriteLine("The Format is Wrong");
            }
            return "";
        }

        static void Main(string[] args)
        {
            Fraction dr = new Fraction(2, 5);
            Console.WriteLine("{0:K}",dr);
        }

        
    }
}
